package com.smart.wap.app;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.smart.common.entities.ajax.AjaxResult;
import com.smart.common.entities.constant.SmartConstant;
import com.smart.manager.member.entities.models.MemberMaterialChicken;
import com.smart.utils.MemberStp;
import com.smart.wap.assembler.ChickenCaches;
import com.smart.wap.bodys.ChickenBody;
import com.smart.wap.service.ChickenService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "移动端-鸡蛋管理")
@RestController
@RequestMapping(SmartConstant.WAP_API_PREFIX + "chicken")
@RequiredArgsConstructor
public class ChickenController {

    private final ChickenService chickenService;

    @ApiOperation(value = "获取鸡(我/他)")
    @GetMapping(value = "getChicken")
    @SaCheckLogin(type = MemberStp.TYPE)
    @ApiOperationSupport(order = 1)
    public AjaxResult<Integer> getChicken(ChickenBody.QueryBody body) {
        Integer chickenList = chickenService.getChicken(body);
        return AjaxResult.data(chickenList);
    }

    @ApiOperation(value = "获取可偷可收的蛋(我/他)")
    @GetMapping(value = "getEgg")
    @SaCheckLogin(type = MemberStp.TYPE)
    @ApiOperationSupport(order = 2)
    public AjaxResult<List<MemberMaterialChicken>> getEgg(ChickenBody.QueryBody body) {
        List<MemberMaterialChicken> egg = chickenService.getEgg(body);
        return AjaxResult.data(egg);
    }

    @ApiOperation(value = "我的蛋列表(我/他)")
    @GetMapping(value = "getEggOne")
    @SaCheckLogin(type = MemberStp.TYPE)
    @ApiOperationSupport(order = 3)
    public AjaxResult<List<MemberMaterialChicken>> getEggOne(ChickenBody.QueryBody body) {
        List<MemberMaterialChicken> egg = chickenService.getEggOne(body);
        return AjaxResult.data(egg);
    }

    @ApiOperation(value = "偷蛋/收蛋(我/他)")
    @GetMapping(value = "addEgg")
    @SaCheckLogin(type = MemberStp.TYPE)
    @ApiOperationSupport(order = 4)
    public AjaxResult<Integer> addEgg(ChickenBody.QueryBody1 body) {
        Integer integer = chickenService.addEgg(body);
        return AjaxResult.data(integer);
    }

    @ApiOperation(value = "获取有蛋用户列表")
    @GetMapping(value = "getInfoList")
    @SaCheckLogin(type = MemberStp.TYPE)
    @ApiOperationSupport(order = 5)
    public AjaxResult<List<ChickenCaches.ChickenInfo>> getInfoList() {
        List<ChickenCaches.ChickenInfo> infoList = chickenService.getInfoOneList();
        return AjaxResult.data(infoList);
    }


    @ApiOperation(value = "获取我的偷取记录列表")
    @GetMapping(value = "getSteal")
    @SaCheckLogin(type = MemberStp.TYPE)
    @ApiOperationSupport(order = 6)
    public AjaxResult<List<ChickenCaches.ChickenSteal>> getSteal() {
        List<ChickenCaches.ChickenSteal> steal = chickenService.getSteal();
        return AjaxResult.data(steal);
    }

    @ApiOperation(value = "获取被偷记录")
    @GetMapping(value = "getStolen")
    @SaCheckLogin(type = MemberStp.TYPE)
    @ApiOperationSupport(order = 7)
    public AjaxResult<List<ChickenCaches.ChickenSteal>> getStolen() {
        List<ChickenCaches.ChickenSteal> steal = chickenService.getStolen();
        return AjaxResult.data(steal);
    }

    @ApiOperation(value = "获取收取记录")
    @GetMapping(value = "getCharge")
    @SaCheckLogin(type = MemberStp.TYPE)
    @ApiOperationSupport(order = 8)
    public AjaxResult<List<ChickenCaches.ChickenSteal>> getCharge() {
        List<ChickenCaches.ChickenSteal> steal = chickenService.getCharge();
        return AjaxResult.data(steal);
    }




    @ApiOperation(value = "获取近7天偷蛋排行榜")
    @GetMapping(value = "getGeeRanking")
    @SaCheckLogin(type = MemberStp.TYPE)
    @ApiOperationSupport(order = 9)
    public AjaxResult<List<ChickenCaches.ChickenRanking>> getGeeRanking() {
        List<ChickenCaches.ChickenRanking> geeRanking = chickenService.getGeeRanking();
        return AjaxResult.data(geeRanking);
    }

}
